package com.hrsaas.ext.spider.handler;

import java.io.IOException;

import com.hrsaas.ext.spider.core.CookieStore;
import com.hrsaas.ext.spider.core.HttpClient;
import com.hrsaas.ext.spider.core.ResponseHandler;

import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpResponseStatus;

/**
 * <p>
 * 功能：不返回任何数据处理
 * <p>
 * @author wangxiaoliang@kanzhun.com
 *
 * 2018年8月2日
 */
public abstract class NoResponseHandler extends ResponseHandler<String> {

	/**
	 * 转换响应数据到实体对象
	 * @param mediaType
	 * @param content
	 * @return
	 * @throws IOException 
	 */
	@Override
	protected Object convert(HttpResponseStatus status, HttpHeaders headers, byte[] content) {
		return null;
	}

	@Override
	protected boolean receive(HttpResponseStatus status, CookieStore cookieStore, HttpHeaders headers, String object) {
		return true;
	}

	@Override
	protected void next(HttpClient client, String object, CookieStore cookieStore, HttpHeaders headers) {
		onNext();
	}

	protected abstract void onNext();

	@Override
	protected void onErrorResponse(HttpResponseStatus status, HttpHeaders headers, String content) {
		System.err.println(content);
	}

}
